package com.qf.rabbitmq.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("fasongdaojiaohuanji",false,false);
    }

    @Bean
    public Queue huanyigeduilie(){
        return new Queue("huanyigeduilie", true, false, false);
    }

    @Bean
    public Binding bingQueue2Fanout(FanoutExchange exchange,Queue huanyigeduilie){
        return BindingBuilder.bind(huanyigeduilie).to(exchange);
    }


    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("directjiaohuanji", false, false);
    }

    @Bean
    public Queue directduilie(){
        return new Queue("directduilie",true,false,false);
    }

    @Bean
    public Binding bingQueue2Direct(DirectExchange exchange,Queue directduilie){
        return BindingBuilder.bind(directduilie).to(exchange).with("error");
    }
}
